package com.doit.day02;

import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.*;

import java.io.IOException;
import java.util.Arrays;
import java.util.List;

public class _07_描述一张表 {
    public static void main(String[] args) throws IOException {

        Connection conn = HbaseUtil.getConn();

        Admin admin = conn.getAdmin();

        //描述这张表  describe
        List<TableDescriptor> tableDescriptors = admin.listTableDescriptors(Arrays.asList(TableName.valueOf("doit:table_name")));
        //获取到表的描述器
        for (TableDescriptor tableDescriptor : tableDescriptors) {
            //通过表的描述器，获取到表名
            TableName tableName = tableDescriptor.getTableName();
            System.out.println("表名是："+new String(tableName.getName()));

            //表的描述器，获取到所有的列族描述器集合
            ColumnFamilyDescriptor[] columnFamilies = tableDescriptor.getColumnFamilies();
            for (ColumnFamilyDescriptor columnFamily : columnFamilies) {
                //列族描述器获取列族名称
                byte[] name = columnFamily.getName();
                System.out.println("列族名称是："+new String(name));
            }
        }


    }
}
